package com.starwish.starwishblog.mapper;

import com.starwish.starwishblog.entity.User;
import com.starwish.starwishblog.vo.HistoryVo;
import com.starwish.starwishblog.vo.UserLoginVo;
import com.starwish.starwishblog.vo.UserOperationVo;
import com.starwish.starwishblog.vo.UserVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface UserMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(User record);


    User selectByPrimaryKey(Integer id);

    List<User> selectAll();

    int updateByPrimaryKey(User record);

    @Select("select * from sw_user where username = #{value}")
    User selectUserByName(String username);

    List<UserVo> selectUserByCons(String name);

    List<User> selectUsersByUid(Integer id);

    List<UserVo> selectFansByUserId(Integer id);

    List<UserVo> selectFollowByUserId(Integer id);

    List<User> selectFollowByUid(Integer id);

    List<User> selectFansByUid(Integer id);

    void insertFollowUser(@Param("userId") Integer userId, @Param("authorId") Integer authorId);

    Integer selectIdByUserIdAndAuthorId(@Param("userId") Integer userId, @Param("authorId") Integer authorId);

    String selectStatusUserIdAndAuthorId(@Param("userId") Integer userId, @Param("authorId") Integer authorId);

    int modifyAuthorById(Integer id);

    int updateLoginTimeByKey(Integer id);

    List<UserVo> selectUserAndFanCount(String username);

    @Update("update sw_user set is_delete = 1,status = 1 where id = #{value}")
    int deleteUserByKey(Integer id);

    int modifyFanCountByKey(@Param("id") Integer id,@Param("fanCount") Integer fanCount);

    int modifyFollowCountByKey(@Param("id") Integer id,@Param("followCount") Integer followCount);

    Integer selectFanCountByKey(Integer id);

    Integer selectFollowCountByKey(Integer id);

    void modifyFollowStatusById(Integer i);

    @Update("update sw_user set status = #{status} where id = #{id}")
    int updateLocked(@Param("id") Integer id,@Param("status") Integer status);

    Integer selectIdByUserIdAndArticleId(@Param("userId") Integer userId,@Param("articleId") Integer articleId);

    int deleteHistoryById(Integer id);

    int insertHistory(HistoryVo historyVo);

    List<HistoryVo> selectUserHistoryList(String username);

    Integer deleteHistoryByUserId(Integer userId);

    int recoverUserHistoryById(Integer userId);

    int recoverAllHistory();

    int deleteAllHistory();

    int modifyHistoryById(@Param("id") Integer id,@Param("isDelete") Integer isDelete);

    List<UserVo> selectFansList(String username);

    int insertUserLoginLog(UserLoginVo loginVo);

    int insertUserOperationLog(UserOperationVo operationVo);

    List<HistoryVo> selectHistoryByUserId(@Param("userId") Integer userId);

}